﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="qljoblang.ascx.cs" Inherits="admin_qljoblang" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<style type="text/css">
    .style1
    {
        width: 128px;
    }
    .style2
    {
        width: 128px;
        height: 79px;
    }
    .style3
    {
        height: 79px;
    }
    .style4
    {
        width: 536px;
    }
    .style5
    {
        height: 79px;
        width: 536px;
    }
</style>
<center>
<table width="100%">
    <tr>
        <td class="style1">Loại Công việc:</td>
        <td class="style4">
            <asp:DropDownList ID="ddlID" runat="server" AutoPostBack="True" 
                DataSourceID="SqlDataSource3" DataTextField="description" DataValueField="id" 
                Height="28px" Width="303px" ValidationGroup="insert" >
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                ConnectionString="<%$ ConnectionStrings:canhbuomxanhconnectionstring %>" 
                SelectCommand="select * from Jobs WHERE id NOT IN (select id from [Jobs_lang] WHERE lang = @lang) ORDER BY [id] DESC">
                <SelectParameters>
                    <asp:ControlParameter ControlID="ddlLang" DefaultValue="vn" Name="lang" />
                </SelectParameters>
            </asp:SqlDataSource>
            </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                ControlToValidate="ddlID" ErrorMessage="*" ValidationGroup="insert">Chưa chọn Loại Công việc</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td class="style1">Ngôn ngữ: </td>
        <td class="style4">
            <asp:DropDownList ID="ddlLang" runat="server" 
                DataSourceID="SqlDataSource1" DataTextField="lang" DataValueField="id" 
                Height="27px" Width="140px" AutoPostBack="True" 
                onselectedindexchanged="ddlLang_SelectedIndexChanged" 
                ondatabound="ddlLang_DataBound" ValidationGroup="insert" >
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:canhbuomxanhconnectionstring %>" 
                SelectCommand="SELECT * FROM [Languages]"></asp:SqlDataSource>
            </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                ControlToValidate="ddlLang" ErrorMessage="*" ValidationGroup="insert">Chưa chọn ngôn ngữ</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td class="style1">Menu: </td>
        <td class="style4">
            <asp:TextBox ID="menu" runat="server" Width="346px" ValidationGroup="insert"></asp:TextBox>
            </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                ControlToValidate="menu" ErrorMessage="*" ValidationGroup="insert">Chưa nhập menu</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td class="style2">Tiêu đề</td>
        <td class="style5">
            <asp:TextBox ID="txtTitle" runat="server" Width="346px" MaxLength="5000" 
                Rows="5" TextMode="MultiLine" ValidationGroup="insert"></asp:TextBox>
        </td>
        <td class="style3">
            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                ControlToValidate="txtTitle" ErrorMessage="*" ValidationGroup="insert">Chưa nhập tiêu đề</asp:RequiredFieldValidator>
            <br />
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                ControlToValidate="txtTitle" ErrorMessage="*" ValidationGroup="insert">Chưa nhập tiêu đề</asp:RegularExpressionValidator>
        </td>
    </tr>
    <tr>
        <td class="style1">Nội dung: </td>
        <td class="style4">
            <fckeditorv2:fckeditor ID="fckContent" runat="server" BasePath="~/fckeditor/" Width="500px">
            </fckeditorv2:fckeditor>
        </td>
        <td>
            &nbsp;</td>
    </tr>
    <tr>
        <td><center>
            </center></td>
        <td class="style4">
            <asp:Button runat="server" ID="addbt" Text="Thêm" 
                onclick="addbt_Click" ValidationGroup="insert"/>
            <asp:HiddenField ID="hdfID" runat="server" />
            <asp:HiddenField ID="hdfContent" runat="server" />
            </td>
        <td>&nbsp;</td>
    </tr>
</table>
</center>
<p>
    &nbsp;</p>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
    AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
    DataKeyNames="id,lang" datasourceid="SqlDataSource2" ForeColor="#333333" 
    GridLines="None" onrowcommand="GridView1_RowCommand" 
    onrowcreated="GridView1_RowCreated" onrowediting="GridView1_RowEditing" 
    PageSize="5" Width="100%" onrowdeleted="GridView1_RowDeleted" 
    onrowdeleting="GridView1_RowDeleting">
    <RowStyle BackColor="#EFF3FB" VerticalAlign="Middle" />
    <EmptyDataRowStyle VerticalAlign="Middle" />
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="White" ForeColor="#459300" HorizontalAlign="Center" />
    <EmptyDataTemplate>
        <asp:Label ID="Label3" runat="server" Text="Chưa có dữ liệu"></asp:Label>
    </EmptyDataTemplate>
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle BackColor="#57A000" Font-Bold="True" ForeColor="White" />
    <Columns>
        <asp:TemplateField HeaderText="ID" SortExpression="id" Visible="False">
            <EditItemTemplate>
                <asp:Label ID="id" runat="server" Text='<%# Eval("id") %>'></asp:Label>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="id" runat="server" Text='<%# Bind("id") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Ngôn ngữ" SortExpression="lang">
            <EditItemTemplate>
                <asp:Label ID="lang" runat="server" Text='<%# Eval("lang") %>'></asp:Label>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="lang" runat="server" Text='<%# Bind("lang") %>'></asp:Label>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Center" />
        </asp:TemplateField>
        <asp:BoundField DataField="menu" HeaderText="Menu" 
            ItemStyle-HorizontalAlign="Center" SortExpression="menu" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
        </asp:BoundField>
        <asp:BoundField DataField="title" HeaderText="Tiêu đề" SortExpression="title" />
        <asp:TemplateField HeaderText="Nội dung" SortExpression="content">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("content") %>'></asp:TextBox>
                
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# Bind("content") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField ShowHeader="False">
            <EditItemTemplate>
                <asp:Button ID="Button1" runat="server" CausesValidation="True" 
                    CommandName="Update" Text="Update" />
                &nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" 
                    CommandName="Cancel" Text="Cancel"  />
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Button ID="Button1" runat="server" CausesValidation="False" 
                    CommandName="Edit" Text="Sửa" />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:CommandField ButtonType="Button" DeleteText="Xoá" 
            ShowDeleteButton="True" />
    </Columns>
    <EditRowStyle BackColor="#003366" VerticalAlign="Middle" />
    <AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:canhbuomxanhconnectionstring %>" 
    SelectCommand="SELECT * FROM [Jobs_lang] ORDER BY [id] DESC" 
    DeleteCommand="DELETE FROM [Jobs_lang] WHERE [id] = @id AND [lang] = @lang" 
    InsertCommand="INSERT INTO Jobs_lang(id, lang, menu, title, [content]) VALUES (@id, @lang, @menu, @title, @content)">
    <DeleteParameters>
        <asp:Parameter Name="id" Type="Int64" />
        <asp:Parameter Name="lang" Type="String" />
    </DeleteParameters>
    <InsertParameters>
        <asp:ControlParameter ControlID="ddlID" Name="id" 
            PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="ddlLang" Name="lang" PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="menu" Name="menu" PropertyName="Text" />
        <asp:ControlParameter ControlID="txtTitle" Name="title" PropertyName="Text" />
        <asp:ControlParameter ControlID="hdfContent" Name="content" PropertyName="Value" />
    </InsertParameters>
</asp:SqlDataSource>
